package com.duanjw.springframework.cglib;

import org.springframework.cglib.core.SpringNamingPolicy;
import org.springframework.cglib.proxy.Enhancer;
import org.springframework.cglib.proxy.MethodInterceptor;
import org.springframework.cglib.proxy.MethodProxy;

import java.lang.reflect.Method;

public class Test {
    public static void main(String[] args) {
        Enhancer enhancer = new Enhancer();
        // cglib基于继承实现
        enhancer.setSuperclass(UserDao.class);
        enhancer.setUseFactory(false);
        enhancer.setNamingPolicy(SpringNamingPolicy.INSTANCE);
        // 添加成员变量$$BeanFactory
        enhancer.setCallback(new MyMethodInterceptor());
        UserDao userDao = (UserDao) enhancer.create();
        userDao.query();
    }


}
